"""meiduo_project URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, register_converter

from apps.users import views

from utils.converters import UsernameConverter

register_converter(UsernameConverter, 'uname')

urlpatterns = [
    path('usernames/<uname:username>/count/', views.UsernameCountView.as_view()),  # 检查用户名是否注册
    path('register/', views.RegisterView.as_view()),                               # 注册
    path('login/', views.LoginView.as_view()),                                     # 登录
    path('logout/', views.LogoutView.as_view()),                                   # 退出登录
    path('info/', views.UserInfoView.as_view()),                                   # 用户中心展示
    path('emails/', views.SaveEmailView.as_view()),                                # 保存邮箱信息
    path('emails/verification/', views.EmailVerifyView.as_view()),                 # 验证邮件
    path('addresses/create/', views.AddressCreateView.as_view()),                  # 新增用户收货地址
    path('addresses/', views.AddressView.as_view()),                               # 展示用户收货地址
    path('addresses/<id>/', views.UpdateAddressView.as_view()),                    # 修改用户收货地址
    path('addresses/<address_id>/default/', views.DefaultAddressView.as_view()),   # 设置默认收货地址
    path('addresses/<address_id>/title/', views.UpdateTitleAddressView.as_view()), # 修改收货地址标题
    path('password/', views.ChangePasswordView.as_view()),                         # 修改密码
]
